package licode.unisop.client.controller;

import licode.unisop.client.utils.SopResult;
import licode.unisop.client.visit.PlatformVisit;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author licode
 */
@RestController
@RequestMapping("/uni-api/v1/platform")
public class SopPlatformController extends SopBaseController {
    @Resource
    private PlatformVisit platformVisit;

    @PostMapping("/cache/update")
    public SopResult<Object> updateCache(@RequestBody Map<String, Object> req) {
        platformVisit.updateCache(req);
        return SopResult.of("OK");
    }

    @PostMapping("/query/lookup")
    public SopResult<Object> findPlatform(@RequestBody Map<String, Object> req) {
        return SopResult.of(platformVisit.findPlatform(req));
    }
}
